<%--
  User: spolyakov
  Date: 19.07.12
  Time: 11:54
--%>

<%@ page import="net.tanesha.recaptcha.ReCaptcha" %>
<%@ page import="net.tanesha.recaptcha.ReCaptchaFactory" %>

<%@taglib uri="http://www.springframework.org/tags" prefix="spring" %>
<%@taglib uri="http://www.springframework.org/tags/form" prefix="form" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

<%@ page contentType="text/html;charset=UTF-8" language="java" %>

<script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery-1.7.2.js"></script>

<SCRIPT type="text/javascript">
    function showSelect(ind) {
        $.ajax({
            url: '${pageContext.request.contextPath}/carservicePage/carservices/getCityList?country_id='+ind,
            dataType: 'html',
            success: function(html) {
                $("#areaTd").html(html);
            }
        });
    }
</SCRIPT>

<div id="content">
    <h2><spring:message code="label.takeReg"/></h2>

    <br/>

    <c:if test="${not empty param}">

        <h3 id="error" > <spring:message code="error.reg"/> </h3>
        <spring:message code="error.reqMsg"/>
        <br/> <br/>
    </c:if>

    <div style="border: 1px solid #000;width: 30%;" align="right">

        <form:form action="${pageContext.request.contextPath}/carservicePage/carservices/save" method="post"
                   commandName="carservice">


            <spring:message code="label.country"/>:
            <form:errors path="idCity.id" id="error" />

            <select name="idCity.idCountry.id" style="width: 146px;"
                    onChange="showSelect(this.options[this.selectedIndex].value)"
                    onclick="showSelect(this.options[this.selectedIndex].value)"
                    >

                <c:forEach items="${countryList}" var="country">
                    <option value="${country.id}">
                        <c:out value="${country.name}"/>
                    </option>
                </c:forEach>

            </select>

            <br/>

            <div id="areaTd">
                <spring:message code="label.city"/>:

                <select  id="areaTd" name="idCity.id" style="width: 146px;">
                    <c:if test="${not empty cityListR}">

                        <c:forEach items="${cityListR}" var="city">
                            <option value="${city.id}">
                                <c:out value="${city.name}"/>
                            </option>
                        </c:forEach>

                    </c:if>
                </select>
                <br/>
            </div>

            <spring:message code="label.name"/>:
            <form:errors path="name" id="error" />
            <label>
                <form:input path="name"/>
            </label>
            <br/>

            <spring:message code="label.address"/>:
            <form:errors path="address" id="error" />
            <form:input path="address"/>
            <br/>

            <spring:message code="label.phone"/>:
            <form:errors path="phone" id="error" />
            <form:input path="phone"/>
            <br/>


            <spring:message code="label.description"/>:
            <br/>
            <form:textarea path="description" rows="8" cols="37"></form:textarea>
                <br/> <br/>

                <br/> <br/>
                <input type="submit" value='<spring:message code="label.takeReg" /> '>


        </form:form>
    </div>

</div>
